package com.design.pattern.chain_of_responsibility;

/**
 * 快递处理点
 */
public abstract class AbstractTransportPointChain {

    protected PackageInfo packageInfo;

    private AbstractTransportPointChain next;//下一个处理对象

    public Boolean status(){
        return false;
    }
    public void doHandler(PackageInfo e){
        this.packageInfo=e;
        if (status()){
            handler();
        }else if (null!=getNext()){

            getNext().doHandler(e);
        }else {
            System.out.println("此快递目的地区不支持配送,将发往发件地.");
        }
    }
    public abstract void handler();

    public AbstractTransportPointChain getNext() {
        return next;
    }

    public void setNext(AbstractTransportPointChain next) {
        this.next = next;
    }

    public void show(String city){
        System.out.println("来自"+packageInfo.getSource()+"的包裹,原寄往"+packageInfo.getDestination()+"现已到达"+city+",即将派送.");
    }
}
